package com.mycompany.lctwitter.action.message;

import javax.annotation.Resource;

import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import com.mycompany.lctwitter.action.AbstractAction;
import com.mycompany.lctwitter.persist.service.MessageService;

@Results( { @Result(name = AbstractAction.SUCCESS, type = "redirect", location = "/message/list") })
public class DeleteAction extends AbstractAction {

    private static final long serialVersionUID = -1413203768696996474L;

    @Resource
    private MessageService messageService;

    private long messageId;

    public void setMessageId(long messageId) {
        this.messageId = messageId;
    }

    @Override
    public String execute() {
        messageService.deleteMessage(messageId);
        return SUCCESS;
    }
}
